<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script src="js/videoformat.js"></script>
    <script type="text/javascript">
        $(function () {
            videoformat.init()
            $.getJSON('json/videoformat.json', function (data) {
                videoformat.setDatas(data)
            })
            $("#btn-effective").click(function(){
                var format = $("#format").val()
                var videoCodec = $("#videoCodec").val()
                var pixelFormat = $("#pixelFormat").val()
                var addSdr = $("#addSdr").val()
                var addSdrv
                if(addSdr == 'true'){
                    addSdrv = true
                } else {
                    addSdrv = false
                }
                var subtitleCodec = $("#subtitleCodec").val()
                var crf = $("#crf").val()
                var audioCodec = $("#audioCodec").val()
                var sampleFormat = $("#sampleFormat").val()

                format = format == "" ? null : format
                videoCodec = videoCodec == "" ? null : videoCodec
                pixelFormat = pixelFormat == "" ? null : pixelFormat
                addSdr = addSdr == "" ? null : addSdr
                subtitleCodec = subtitleCodec == "" ? null :subtitleCodec
                audioCodec = audioCodec == "" ? null : audioCodec
                sampleFormat = sampleFormat == "" ? null : sampleFormat

                var effective = videoformat.isEffective(format, videoCodec, pixelFormat, addSdrv, subtitleCodec, crf, audioCodec, sampleFormat)
                var list = videoformat.getList(format, videoCodec, pixelFormat, addSdrv, subtitleCodec, crf, audioCodec, sampleFormat)
                var toService = videoformat.parameterTransformation(format, videoCodec, pixelFormat, addSdrv, subtitleCodec, crf, audioCodec, sampleFormat)
                console.log('effective', effective)
                console.log('list', list)
                console.log('toService', toService)
            })
        })
    </script>
</head>
<body>
<div>
    <table>
        <input id="format" value="mp4"/>
        <input id="videoCodec" value="HEVC"/>
        <input id="pixelFormat" value="yuv420p"/>
        <input id="addSdr" value="true"/>
        <input id="subtitleCodec" value="Timed Text"/>
        <input id="crf" value="11"/>
        <input id="audioCodec" value="AAC"/>
        <input id="sampleFormat" value="s16"/>
        <input id="btn-effective" type="button" value="测试"/>
    </table>
</div>
</body>
</html>